<template>
  <el-switch
    ref="fieldEditor"
    v-model="formRow.row[field.id]"
    :disabled="previewStatus || field.options.disabled"
    :active-text="field.options.activeText"
    :inactive-text="field.options.inactiveText"
    :active-color="field.options.activeColor"
    :inactive-color="field.options.inactiveColor"
    :width="field.options.switchWidth"
  />
</template>

<script>
/* eslint-disable vue/require-default-prop */
/* eslint-disable eol-last */
import tableMixin from "./tableMixin";

export default {
  name: "table_switch_unit",
  componentName: "FieldWidget",
  mixins: [tableMixin],
  props: {
    designer: Object,
    field: Object,
    formRow: Object,
    formData: Object,
    designState: {
      type: Boolean,
      default: false,
    },
  },
  // inject: ["refList", "formConfig", "globalOptionData", "globalModel"],
  data() {
    return {
      oldFieldValue: null,
      fieldModel: null,
      rules: [],
    };
  },
  computed: {
    inputType() {
      if (this.field.options.type === "number") {
        return "text";
      }
      return this.field.options.type;
    },
  },
  beforeCreate() {
    /* 这里不能访问方法和属性！！ */
  },
  created() {
    /* 注意：子组件mounted在父组件created之后、父组件mounted之前触发，故子组件mounted需要用到的prop
         需要在父组件created中初始化！！ */
    // this.initFieldModel();
    // this.registerToRefList();
    // this.buildFieldRules();
    this.handleOnCreated();
  },
  mounted() {
    this.initEventHandler();
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
@import "../../../../../../styles/global.scss"; //* form-item-wrapper已引入，还需要重复引入吗？ *//
</style>
